
using System.Web.UI.HtmlControls;
using System;
using System.Configuration;
using System.Drawing;
using System.Data;
using System.Web.UI.WebControls;
using Microsoft.VisualBasic;
using System.Collections;
using System.Web.UI;
using System.Web;


using System.IO;
using System.Text;
using System.Drawing.Imaging;
//using com.ddsc.database;
using DDSC.OracleADO;
using com.ddsc.common;
using SMAS;
using System.Resources;
using System.Data.OracleClient;

//==================================================================================================
//程式編號   :           VNDW0072                    版本 :  1.00.00
//
//程式名稱   :			 樂e購商品文案維護
//
//系統分析師 :           Joe
//
//程式設計師 :           Tino
//
//編寫日期   :           2013/01/31

//修改記錄   :

//修改案編號      修改日期      修改人員          修改原因            修　改　內　容

//－－－－       －－－－      －－－－     －－－－－－－－       －－－－－－－－－－－－－－－－
//P3513M0025     20130131      TinoWeng                             Init                    I
//
//==================================================================================================
namespace smasb2b
{
	public class VNDW0072 : BasePage
	{
		
		DataBase DataBase = new DataBase();
		StringBuilder sb = new StringBuilder();
		protected System.Web.UI.WebControls.Label lblDOC_SPEC;
		string strSPLIT = "@@@SPLIT@@@";
#region  Web Form 設計工具產生的程式碼
		
		//此為 Web Form 設計工具所需的呼叫。
		[System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
		{
			
		}
		protected ddscControlLibrary.SubmitButtonCtrl btnApproveDoc;
		protected ddscControlLibrary.SubmitButtonCtrl btnExitDoc;
		protected System.Web.UI.WebControls.Label lblBody2;
		protected System.Web.UI.WebControls.Image imgDOC_PIC2;
		protected System.Web.UI.WebControls.Image imgDOC_PIC1;
		protected System.Web.UI.WebControls.Label lblBody1;
		protected System.Web.UI.WebControls.Image imgDOC_PIC3;
		protected System.Web.UI.WebControls.Label lblBody3;
		protected System.Web.UI.WebControls.Image imgDOC_PIC4;
		protected System.Web.UI.WebControls.Label lblBody4;
		protected System.Web.UI.WebControls.Image imgDOC_PIC5;
		protected System.Web.UI.WebControls.Label lblBody5;
		protected System.Web.UI.WebControls.Image imgDOC_SPEC_PIC;
		
		//注意: 下列預留位置宣告是 Web Form 設計工具需要的項目。
		//請勿刪除或移動它。
		private System.Object designerPlaceholderDeclaration;
		
		private void Page_Init(System.Object sender, System.EventArgs e)
		{
			//CODEGEN: 此為 Web Form 設計工具所需的方法呼叫
			//請勿使用程式碼編輯器進行修改。
			InitializeComponent();
		}
		
#endregion
		
		private DataTable createErrorTable(string mError)
		{
			
			dbReturnInfo dbInfo = new dbReturnInfo("info");
			dbInfo.AddNewRow();
			dbInfo.setReturnDataValue("F", System.Convert.ToString(999), 0, mError);
			return dbInfo.getReturnDataTable();
		}
		
		private string[] GetDocBody(string sDest, string s)
		{
			string[] ss = new string[3];
			if (sDest.IndexOf(s) == -1)
			{
				ss[0] = sDest;
				ss[1] = "";
			}
			else
			{
				ss[0] = sDest.Substring(0, sDest.IndexOf(s));
				ss[1] = sDest.Substring(sDest.IndexOf(s) + s.Length);
			}
			
			return ss;
		}

        private void Page_Load(System.Object sender, System.EventArgs e)
        {
            //在這裡放置使用者程式碼以初始化網頁
            try
            {
                if (!Page.IsPostBack)
                {
                    if (!(this.Request["ACTION_TYPE"] == "APPROVE"))
                    {
                        this.btnApproveDoc.Visible = false;
                    }
                    string strCode = System.Convert.ToString(this.Request["B2C_CODE"].ToString().Trim());
                    string strVer = System.Convert.ToString(this.Request["DOC_VER"].ToString().Trim());
                    DataBase.clearSB(sb);
                    sb.Append(" Select * from B2C_WEB_CONTENT ");
                    //Tony : 1.修改SQL語法使用參數，不組字串
                    //sb.Append(" WHERE  CODE = \'" + strCode + "\' AND DOC_VER =\'" + (int.Parse(strVer)).ToString() + "\'");
                    sb.Append(" WHERE  CODE = :strCode AND DOC_VER =:strVer");
                    //Tony : 2.設定動態參數物件
                    ArrayList m_arrParam = new ArrayList();
                    dbAccess dba = new dbAccess();
                    m_arrParam.Add(dba.GetOracleParam(":strCode", strCode));
                    m_arrParam.Add(dba.GetOracleParam(":strVer", (int.Parse(strVer)).ToString()));

                    //Tony : 3.修改執行方法Overload
                    //DataSet ds_detal = DataBase.Query_CLASS(sb);
                    DataSet ds_detal = DataBase.Query_CLASS(sb, m_arrParam);

                    int i = 0;
                    if (!(ds_detal == null) && ds_detal.Tables[0].Rows[0]["ReturnCode"] != "100" && ds_detal.Tables[0].Rows[0]["ReturnCode"] != "999")
                    {

                        for (i = 0; i <= ds_detal.Tables[1].Rows.Count - 1; i++)
                        {
                            DataRow dr = ds_detal.Tables[1].Rows[i];
                            int aInt = 9;
                            string[] arrDOC_BODY = new string[aInt + 1];
                            string sDest = "";
                            string sArr = dr["DOC_BODY"].ToString();
                            for (int iArr = 0; iArr <= aInt - 1; iArr++)
                            {
                                string[] ss = new string[3];
                                if (iArr == 0)
                                {
                                    sDest = sArr;
                                }
                                ss = GetDocBody(sDest, strSPLIT);
                                arrDOC_BODY[iArr] = HttpUtility.HtmlDecode(ss[0]);
                                sDest = ss[1];
                            }
                            //arrDOC_BODY = dr("DOC_BODY").ToString.Split(strSPLIT.ToCharArray())
                            string strDOCP = string.Empty;
                            if (arrDOC_BODY[0] != "")
                            {
                                this.lblBody1.Text = "<br />" + arrDOC_BODY[0] + "<br />";
                            }
                            if (dr["DOC_PIC1_PATH"].ToString() != "")
                            {
                                this.imgDOC_PIC1.Visible = true;
                                strDOCP = System.Convert.ToString(dr["DOC_PIC1_PATH"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    //									strDOCP = "/SMAS/IMAGE/B2C/B2C_IMAGES/" + strDOCP.Substring(38);
                                    //  strDOCP = "\\smasweb03\\smas\\Image\\B2C\\B2C_Images_Test\\" + strDOCP.Substring(38);
                                }
                                this.imgDOC_PIC1.ImageUrl = strDOCP;

                            }
                            else
                            {
                                this.imgDOC_PIC1.Visible = false;
                            }

                            if (arrDOC_BODY[1] != "")
                            {
                                this.lblBody2.Text = "<br />" + arrDOC_BODY[1] + "<br />";
                            }
                            if (dr["DOC_PIC2_PATH"].ToString() != "")
                            {
                                this.imgDOC_PIC2.Visible = true;
                                strDOCP = System.Convert.ToString(dr["DOC_PIC2_PATH"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    //   strDOCP = "\\smasweb03\\smas\\Image\\B2C\\B2C_Images_Test\\" + strDOCP.Substring(38);
                                }
                                this.imgDOC_PIC2.ImageUrl = strDOCP;
                            }
                            else
                            {
                                this.imgDOC_PIC2.Visible = false;
                            }
                            if (arrDOC_BODY[2] != "")
                            {
                                this.lblBody3.Text = "<br />" + arrDOC_BODY[2] + "<br />";
                            }
                            if (dr["DOC_PIC3_PATH"].ToString() != "")
                            {
                                this.imgDOC_PIC3.Visible = true;
                                strDOCP = System.Convert.ToString(dr["DOC_PIC3_PATH"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    //  strDOCP = "\\smasweb03\\smas\\Image\\B2C\\B2C_Images_Test\\" + strDOCP.Substring(38);
                                }
                                this.imgDOC_PIC3.ImageUrl = strDOCP;
                            }
                            else
                            {
                                this.imgDOC_PIC3.Visible = false;
                            }
                            if (arrDOC_BODY[3] != "")
                            {
                                this.lblBody4.Text = "<br />" + arrDOC_BODY[3] + "<br />";
                            }
                            if (dr["DOC_PIC4_PATH"].ToString() != "")
                            {
                                this.imgDOC_PIC4.Visible = true;
                                strDOCP = System.Convert.ToString(dr["DOC_PIC4_PATH"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    //  strDOCP = "\\smasweb03\\smas\\Image\\B2C\\B2C_Images_Test\\" + strDOCP.Substring(38);
                                }
                                this.imgDOC_PIC4.ImageUrl = strDOCP;
                            }
                            else
                            {
                                this.imgDOC_PIC4.Visible = false;
                            }
                            if (arrDOC_BODY[4] != "")
                            {
                                this.lblBody5.Text = "<br />" + arrDOC_BODY[4] + "<br />";
                            }
                            if (dr["DOC_PIC5_PATH"].ToString() != "")
                            {
                                this.imgDOC_PIC5.Visible = true;
                                strDOCP = System.Convert.ToString(dr["DOC_PIC5_PATH"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    //   strDOCP = "\\smasweb03\\smas\\Image\\B2C\\B2C_Images_Test\\" + strDOCP.Substring(38);
                                }
                                this.imgDOC_PIC5.ImageUrl = strDOCP;
                            }
                            else
                            {
                                this.imgDOC_PIC5.Visible = false;
                            }
                            if (arrDOC_BODY[5] != "")
                            {
                                this.lblDOC_SPEC.Text = "<br />" + arrDOC_BODY[5] + "<br />";
                            }
                            if (dr["DOC_SPEC_PIC"].ToString() != "")
                            {
                                this.imgDOC_SPEC_PIC.Visible = true;
                                strDOCP = System.Convert.ToString(dr["DOC_SPEC_PIC"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    //    strDOCP = "\\smasweb03\\smas\\Image\\B2C\\B2C_Images_Test\\" + strDOCP.Substring(38);
                                }
                                this.imgDOC_SPEC_PIC.ImageUrl = strDOCP;
                            }
                            else
                            {
                                this.imgDOC_SPEC_PIC.Visible = false;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                showException(ex.Message);
            }
        }
		
		private void btnApproveDoc_Click(System.Object sender, System.EventArgs e)
		{
			
			
		}
	}
	
}
